/*
 * 存储数据
 * id为url参数，key是需要存储数据的键名，val为存储的值
 * */
export function savaToLocal(id,key,value){
   let seller =window.localStorage.__seller__;
  if(!seller){
      seller = {};
      seller[id] = {};
      seller[id][key] = value;
  }else{
      seller = JSON.parse(seller);
      if(!seller[id]){
          seller[id] = {};
      }
  }
  seller[id][key] = value;
    window.localStorage.__seller__ = JSON.stringify(seller)
};

/*
 * 读取localStorage数据
 * def为默认读取数据
 * */
export function loadFromLocal (id,key,def){
    let seller = window.localStorage.__seller__
    if(!seller){
        return def;
    }
    seller = JSON.parse(seller)[id];
    if(!seller){
        return def;
    }
    let ret = seller[key];
    return ret || def;
};